package com.dbapp.shopping.security;

import com.dbapp.shopping.domain.User;
import lombok.Data;
import org.springframework.security.crypto.password.PasswordEncoder;

@Data
public class RegistrationForm {

    private String username;
    private String password;
    private String name;

    public User toUser(PasswordEncoder passwordEncoder) {
        User user = new User(username);
        user.setPassword(passwordEncoder.encode(password));
        user.setName(name);
        return user;
    }
}
